package com.kvn.dubbo;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import com.kvn.dubbo.service.DefaultDemoService;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

import java.io.IOException;

/**
 * Created by wangzhiyuan on 2018/12/27
 */
@SpringBootApplication
@EnableDubbo(scanBasePackages = "com.kvn.dubbo.service")
public class DubboProviderDemo {

    public static void main(String[] args) throws IOException {

        new SpringApplicationBuilder(DubboProviderDemo.class)
                .web(WebApplicationType.NONE)
                .run(args);

        System.out.println("DubboProviderDemo started successfully!");

    }

    public static void programStart() {
        ServiceConfig<DemoService> service = new ServiceConfig<>();
        service.setApplication(new ApplicationConfig("first-dubbo-provider"));
        service.setRegistry(new RegistryConfig("zookeeper://10.202.200.133:2181"));
        service.setInterface(DemoService.class);
        service.setRef(new DefaultDemoService());
        service.export();
        System.out.println("first-dubbo-provider is running.");
        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
